package no.steras.opensamlbook.login;

import no.steras.opensamlbook.sp.SPConstants;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * login uot
 *
 * @author jiabin.zheng@zoomcloud.cn
 * @create 2018-05-16 10:40
 **/
public class LoginOutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Object obj = req.getSession().getAttribute(SPConstants.AUTHENTICATED_SESSION_ATTRIBUTE);
        if (obj != null) {
            req.getSession().removeAttribute(SPConstants.AUTHENTICATED_SESSION_ATTRIBUTE);
        }
        resp.sendRedirect("/saml");
    }
}
